/*
Purpose: Run main paper analyses using ACS data
*/

/* these flags turn on and off different parts of the code */
/* only need to create the analysis file once unless it's revised */
global create_analysis_file=1
global reg_summary = 1
global reg_read = 1
global math_read_comp = 1
global covars0       "math08sd92_gap1 male i.race i.yob  i.fips_birth i.age i.year"
global covars0_statefe "state_year_adj_score_gap1 male i.race i.yob  i.fips_birth i.age i.year"
global covars0_adj_parcol_census "state_year_adj_score_gap1 norm_either_par_gcol_2yr male i.race i.yob  i.fips_birth i.age i.year"
global covars0_read      "read08sd98_gap1 male i.race i.yob  i.fips_birth i.age i.year"
global covars0_read_parcol_census "read08sd98_gap1 norm_either_par_gcol_2yr male i.race i.yob  i.fips_birth i.age i.year"
global covars0_math_readcomp "math08sd92_gap1 norm_either_par_gcol_2yr male i.race i.yob  i.fips_birth i.age i.year"

set type double
set maxiter 5000
set varabbrev off

global sd92 = 36.3153155648024

if $create_analysis_file==1 {
	
import delimited "data/raw/USACPIALLAINMEI",clear
gen year=real(substr(date,1,4))
keep if year>=2000&year<=2019
sort year
gen inflator=usacpiallainmei[19]/usacpiallainmei
keep inflator year
save "data/clean/inflator",replace

use "data/clean/math8_normed", clear
keep year state_fips scale_score_norm

gen yob = year - 13
ren state_fips fips
ren scale_score_norm math08sd92
drop year

tsset fips yob
tsfill

gen math08sd92_gap1=math08sd92
replace math08sd92_gap1=(L.math08sd92+F.math08sd92)/2 if L.math08sd92!=.&F.math08sd92!=.

label var math08sd92_gap1 "Math scores imputed linearly for 1-year gaps"

gen temp=math08sd92_gap1 if yob==1977
egen math08_1977=mean(temp),by(fips)
drop temp

save "data/clean/naep_data",replace

use "data/clean/read8_normed", clear
keep year state_fips scale_score_norm

gen yob = year - 13
ren state_fips fips
ren scale_score_norm read08sd98
drop year

tsset fips yob
tsfill

gen read08sd98_gap1=read08sd98
replace read08sd98_gap1=(L.read08sd98+F.read08sd98)/2 if L.read08sd98!=.&F.read08sd98!=.

label var read08sd98_gap1 "Reading scores imputed linearly for 1-year gaps"


gen temp=read08sd98_gap1 if yob==1985
egen read08_1985=mean(temp),by(fips)
drop temp


save "data/clean/naep_data_read",replace


*reading in pums data (this is just the unzipped file downloaded from ipums)
use "data/raw/usa_00008.dta"

gen unemp = (empstat == 2)
replace unemp =. if empstat == 0 | empstat == 3

*dropping those with allocated covariates (allocated income and education set to missing below)
drop if qage==4
drop if qsex==4
drop if qbpl==4
drop if qrace==4

sort year
merge m:1 year using "data/clean/inflator"

*year of birth and state of birth
rename birthyr yob
gen fips=bpl if bpl>=1&bpl<=56
*dropping those born in dc
drop if bpl==11

*defining income and earn outomes (trimming at 1st and 99th percentiles)
replace incearn=incearn*inflator
replace incwage=incwage*inflator

gen lnincearn=ln(incearn) if qincwage!=4&qincbus!=4
gen lnincwage=ln(incwage) if qincwage!=4

winsor2 lnincearn,cut(1 99) replace
winsor2 lnincwage,cut(1 99) replace
label var lnincearn "Log of earnings"

*defining occupational prestige measure (missing in 2018, so losing 8th graders from 2003)
replace occscore=. if qocc!=0|occscore==0
label var occscore "Occupational prestige score"
*also replacing occsoc
replace occsoc="" if qocc!=0
gen occsoc1 = substr(occsoc,1,2) if occsoc!=""
gen occsoc2 = substr(occsoc,3,4) if occsoc!=""
egen occsoc_hyp = concat(occsoc1 occsoc2), punct("-")
replace occsoc_hyp = "" if occsoc_hyp=="-"
drop occsoc occsoc1 occsoc2
ren occsoc_hyp occsoc

*food stamp receipt
replace foodstmp=. if qfoodstm!=0
label var foodstmp "Food stamp receipt"

*usual hours worked per week
replace uhrswork=. if uhrswork==0|quhrswor!=0
label var uhrswork "Usual hours worked per week"

*institutionalized
gen institutionalized=(gq==3) if year==2000|year>=2006
label var institutionalized "Institutionalized"

*ever married
gen byte ever_married=(marst>=1&marst<=5) if marst<=6&qmarst==0
label var ever_married "Ever married"

*own home
gen byte own_home=(ownershp==1) if ownershp!=0&qownersh==0
label var own_home "Own home"

*educational attainment
gen byte lths= (educd>=1&educd<=61) if qeduc==0&educ!=0
gen byte hsgradonly=(educd>=62&educd<=64) if qeduc==0&educ!=0 
gen byte somecoll=(educd>=65&educd<=71) if qeduc==0&educ!=0
gen byte aadeg=(educd==81) if qeduc==0&educ!=0
gen byte badegonly=(educd==101) if qeduc==0&educ!=0
gen byte graddeg=(educd>=114&educd<=116) if qeduc==0&educ!=0
gen byte baplus=badegonly+graddeg
gen byte hsplus=hsgradonly+somecoll+aadeg+baplus
gen byte somecollplus=somecoll+aadeg+baplus

label var lths "Less than high school"
label var hsgradonly "High school graduate, no college"
label var somecoll "Some college"
label var aadeg "Associate's degree"
label var badegonly "Bachelor's degree, no grad school"
label var graddeg "Graduate degree"
label var baplus "Bachelor's degree or more"
label var hsplus "High school graduate or more"
label var somecollplus "Some college or more"

*enrolled full time OR enrolled in college/grad school
gen ftwork_enroll=(uhrswork>=30&uhrswork!=.)|(school==2&(gradeatt==6|gradeatt==7)) if quhrswor==0&qschool==0&qgradeat==0 //!Amo changed this to flag those working 30+ hrs to match irs def 
gen college_enroll=(school==2&(gradeatt==6|gradeatt==7)) if qschool==0&qgradeat==0

label var ftwork_enroll "Working full time or enrolled in college/grad"
label var college_enroll "Enrolled in college/grad"

*defining race/ethnicity and other demographics
gen byte hispanic=(hispan>=1) if hispan!=.&qhispan!=4

replace race=. if race==0|qrace==4
gen byte whitenh=(race==1&hispanic==0)   if hispan!=.&race!=.
gen byte blacknh=(race==2&hispanic==0)   if hispan!=.&race!=.
gen byte natam=(race==3&hispanic==0) if hispan!=.&race!=.
gen byte asian=(race>=4&race<=6&hispanic==0) if hispan!=.&race!=.

rename race racecat
gen race=1*whitenh+2*blacknh+3*hispanic+4*asian+5*natam if racecat!=.&hispanic!=.
replace race=. if race==0

gen byte male=(sex==1)   if qsex==0

*Caluate mothers age at birth for those 30 or younger
gen mothers_age=age-eldch if eldch!=99 & sex==2 & age<=30
gen teenage_mother = (mothers_age<=19) if sex==2&age<=30
label var teenage_mother "Had child as teenager"

capture drop _merge

*adding in NAEP data
sort fips yob
merge m:1 fips yob using "data/clean/naep_data"

drop if _merge==2
capture drop _merge

merge m:1 fips yob using "data/clean/naep_data_read"

drop if _merge==2
capture drop _merge

egen fips_year=group(fips year)
egen fips_yob=group(fips yob)

keep if fips!=.&yob!=.&age!=.

*region dummies
recode fips (9 23 25 33 44 50 34 36 42 = 1 "Northeast") (17 18 26 39 55 19 20 27 29 31 38 46 = 2 "Midwest") (10 11 12 13 24 37 45 51 54 1 21 28 47 5 22 40 48 = 3 "South") (4 8 16 30 32 35 49 56 2 6 15 41 53 =4 "West"), gen(region)
recode statefip (9 23 25 33 44 50 34 36 42 = 1 "Northeast") (17 18 26 39 55 19 20 27 29 31 38 46 = 2 "Midwest") (10 11 12 13 24 37 45 51 54 1 21 28 47 5 22 40 48 = 3 "South") (4 8 16 30 32 35 49 56 2 6 15 41 53 =4 "West"), gen(regionres)
*census division dummies
recode fips (9 23 25 33 44 50 =1 "New England") (34 36 42 =2 "Mid Atlantic") (17 18 26 39 55 =3 "E North Central")  (19 20 27 29 31 38 46 = 4 "W North Central") (10 11 12 13 24 37 45 51 54 =5 "South Atlantic") (1 21 28 47 =6 "E South Central") (5 22 40 48 =7 "W South Central")  (4 8 16 30 32 35 49 56 =8 "Mountain")  (2 6 15 41 53 = 9 "Pacific"),gen(division_birth)
recode statefip (9 23 25 33 44 50 =1 "New England") (34 36 42 =2 "Mid Atlantic") (17 18 26 39 55 =3 "E North Central")  (19 20 27 29 31 38 46 = 4 "W North Central") (10 11 12 13 24 37 45 51 54 =5 "South Atlantic") (1 21 28 47 =6 "E South Central") (5 22 40 48 =7 "W South Central")  (4 8 16 30 32 35 49 56 =8 "Mountain")  (2 6 15 41 53 = 9 "Pacific"),gen(division_resid)

rename fips fips_birth
rename statefip fips_resid
rename region regionbrth

label var fips_birth "State of Birth"
label var fips_resid "State of Residence"
label var math08sd92 "Math 8th Gr"
label var read08sd98 "Read 8th Gr"
label var regionbrth "Region of Birth"
label var regionres "Region of Residence"
label var yob "Year of Birth"
label var year "Census Year"
label var age "Age"




save "data/clean/tempanal",replace
}


if $reg_summary==1 {

//making sure we're not keeping states dropped by NAEP
import excel "data/raw/state_scale_score.xls", cellrange("A9:E804") first clear
tab Jurisdiction Year if Averagescalescore=="‡"
drop if Averagescalescore=="—"|Averagescalescore=="‡"
drop if Jurisdiction=="DoDEA"|Jurisdiction=="National public"
destring Averagescalescore, replace
drop if Year=="2000¹"
replace Year = substr(Year,1,4)
destring Year, replace
statastates, name(Jurisdiction)
drop _merge
ren Year year
ren state_fips fips
tempfile state_scores
save `state_scores', replace

use "data/clean/state_year_indices", clear
merge 1:1 fips year using `state_scores'
drop if _merge==1|_merge==2 //dropping states/years for which NAEP does not report a state score
drop Jurisdiction-_merge

tsset fips year
tsfill

foreach var of varlist state_year_adj_score {
	gen `var'_gap1=`var'
	replace `var'_gap1=(L.`var'+F.`var')/2 if L.`var'!=.&F.`var'!=.
}

gen yob = year - 13

ren fips fips_birth

merge 1:1 yob fips_birth using "data/clean/state_year_ses_index"
keep if _merge==3
drop _merge

keep fips_birth yob *_gap1 norm_either_par_gcol_2yr
drop if state_year_adj_score_gap1==.

merge 1:m fips_birth yob using "data/clean/tempanal"
drop _merge

merge m:1 yob fips_birth using "data/clean/state_unemployment" // drops 2002 yob
keep if _merge==3
drop _merge

label var unemp_rate_age18 "State unemp at age 18"

merge m:1 yob fips_birth using "data/clean/med_income_age13_child"
drop if _merge==2
drop _merge

label var lnmed_income_age13_kid_sm "Ln med income hhs w child at age 13 3yr"

merge m:1 yob fips_birth using "data/clean/birthweight_data"
drop if _merge==2
drop _merge
label var lowbirwt_pct "% of births with low birth weight"
label var vlowbirwt_pct "% of births with very low birth weight"

// occupation year: year of SOC code used in ACS data
gen socyear = 2000 if year <= 2009
replace socyear = 2010 if year <= 2017 & year > 2009
replace socyear = 2018 if year > 2017 & year != .

merge m:1 occsoc socyear using "data/clean/math_level"
drop if _merge==2
drop _merge

label var math_level "Occupation math level from O-NET"
 
label var math08sd92_gap1 "Math 08 imp 1 yr gap"
replace state_year_adj_score_gap1 = (state_year_adj_score_gap1) / $sd92

preserve
 keep if math08sd92_gap1!=. & age>=28
 collapse (mean) age [pw=perwt]
 scalar mean_age = age[1]
 restore
 
gen mathbyage=math08sd92_gap1*(age-`=mean_age')

local age28_vars lnincearn //occscore unemp foodstmp uhrswork ever_married own_home


foreach age28_var of local age28_vars {

eststo clear
eststo orig:  reg   `age28_var' $covars0                  if age>=28 [pw=perwt],robust cluster(fips_yob)
eststo state_fe: quietly reg `age28_var' $covars0_statefe            if age>=28 [pw=perwt],robust cluster(fips_yob)
eststo statefe_par: quietly reg `age28_var' $covars0_adj_parcol_census           if age>=28 [pw=perwt],robust cluster(fips_yob)
eststo fips_resid: quietly reg `age28_var' $covars0_adj_parcol_census i.fips_resid           if age>=28 [pw=perwt],robust cluster(fips_yob)
eststo dobyob: quietly reg `age28_var' $covars0_adj_parcol_census i.fips_resid division_birth#yob        if age>=28 [pw=perwt],robust cluster(fips_yob)
eststo econ_low_kid: quietly reg `age28_var' unemp_rate_age18 lnmed_income_age13_kid_sm lowbirwt_pct  $covars0_adj_parcol_census i.fips_resid division_birth#yob        if age>=28 [pw=perwt],robust cluster(fips_yob)
eststo stateresbyyear: quietly reg `age28_var' $covars0_adj_parcol_census i.fips_resid division_birth#yob fips_resid#year        if age>=28 [pw=perwt],robust cluster(fips_yob)
eststo sobyobtrend:     quietly reg `age28_var' $covars0_adj_parcol_census  i.fips_resid division_birth#yob fips_birth#c.yob  if age>=28 [pw=perwt],robust cluster(fips_yob)



esttab using "results/`age28_var'_summary_census", mlabel("original specification" "bg-adjusted math score (state FE)" "adj math score par gcol" "add state resid" "add dob#yob" "econ low birthwt inc 3yr child" "state resid by year" "state birth by yob child") csv cells(b(star fmt(3))  se(par fmt(3))) replace label order(math08sd92_gap1 state_year_adj_score_gap1 norm_either_par_gcol_2yr unemp_rate_age18 lnmed_income_age13_kid_sm lowbirwt_pct vlowbirwt_pct)

}


eststo clear
eststo eq1: quietly reg lnincearn $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq2: quietly reg hsplus    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=23, robust cluster(fips_yob)	
eststo eq3: quietly reg somecollplus    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=23, robust cluster(fips_yob)
eststo eq4: quietly reg baplus    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=23, robust cluster(fips_yob)
eststo eq5: quietly reg graddeg    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=23, robust cluster(fips_yob)
eststo eq6: quietly reg occscore    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq7: quietly reg unemp    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq8: quietly reg foodstmp    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq9: quietly reg uhrswork    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq10: quietly reg ever_married    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq11: quietly reg own_home    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq12: quietly reg teenage_mother    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if male==0&age<=30, robust cluster(fips_yob)
eststo eq13: quietly reg institutionalized  $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=18&age<=24&(male==1), robust cluster(fips_yob)
eststo eq14: quietly reg college_enroll  $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=19&age<=24, robust cluster(fips_yob)
eststo eq15: quietly reg ftwork_enroll    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=19&age<=24, robust cluster(fips_yob)
eststo eq16: quietly reg math_level    $covars0_adj_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
esttab using "results/allvars_stateadj_parentcol_census_dobyob",  csv cells(b(star fmt(3))  se(par fmt(3))) replace

eststo clear
eststo eq1: reg state_year_adj_score_gap1 norm_either_par_gcol_2yr male i.race i.yob  i.fips_birth i.age i.year i.fips_resid division_birth#yob fips_birth#c.yob [pw=perwt] if age >= 28, robust cluster(fips_yob)
esttab using "results/r2_analysis",  csv r2 cells(b(star fmt(3))  se(par fmt(3))) mlabel("with trend 28+") replace

}

if $reg_read==1 {
	use "data/clean/tempanal", clear
	
	merge m:1 yob fips_birth using "data/clean/state_year_ses_index"
	drop if _merge==2
	drop _merge
	
	// occupation year: year of SOC code used in ACS data
	gen socyear = 2000 if year <= 2009
	replace socyear = 2010 if year <= 2017 & year > 2009
	replace socyear = 2018 if year > 2017 & year != .

	merge m:1 occsoc socyear using "data/clean/math_level"
	drop if _merge==2
	drop _merge

	label var math_level "Occupation math level from O-NET"
	
eststo clear
eststo eq1: quietly reg lnincearn $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq2: quietly reg hsplus    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=23, robust cluster(fips_yob)	
eststo eq3: quietly reg somecollplus    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=23, robust cluster(fips_yob)
eststo eq4: quietly reg baplus    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=23, robust cluster(fips_yob)
eststo eq5: quietly reg graddeg    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=23, robust cluster(fips_yob)
eststo eq6: quietly reg occscore    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq7: quietly reg unemp    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq8: quietly reg foodstmp    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq9: quietly reg uhrswork    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq10: quietly reg ever_married    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq11: quietly reg own_home    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
eststo eq12: quietly reg teenage_mother    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if male==0&age<=30, robust cluster(fips_yob)
eststo eq13: quietly reg institutionalized  $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=18&age<=24&(male==1), robust cluster(fips_yob)
eststo eq14: quietly reg college_enroll  $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=19&age<=24, robust cluster(fips_yob)
eststo eq15: quietly reg ftwork_enroll    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=19&age<=24, robust cluster(fips_yob)
eststo eq16: quietly reg math_level    $covars0_read_parcol_census i.fips_resid division_birth#yob [pw=perwt] if age>=28, robust cluster(fips_yob)
esttab using "results/allvars_stateadj_parentcol_census_read",  csv cells(b(star fmt(3))  se(par fmt(3))) replace

}

if $math_read_comp==1 {
	
	use "data/clean/tempanal", clear
	
	merge m:1 yob fips_birth using "data/clean/state_year_ses_index"
	drop if _merge==2
	drop _merge
	
	// occupation year: year of SOC code used in ACS data
	gen socyear = 2000 if year <= 2009
	replace socyear = 2010 if year <= 2017 & year > 2009
	replace socyear = 2018 if year > 2017 & year != .

	merge m:1 occsoc socyear using "data/clean/math_level"
	drop if _merge==2
	drop _merge

	label var math_level "Occupation math level from O-NET"


eststo clear
eststo eq1: quietly reg lnincearn $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=28 & yob >= 1983, robust cluster(fips_yob)
eststo eq2: quietly reg hsplus    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=23 & yob >= 1983, robust cluster(fips_yob)	
eststo eq3: quietly reg somecollplus    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=23 & yob >= 1983, robust cluster(fips_yob)
eststo eq4: quietly reg baplus    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=23 & yob >= 1983, robust cluster(fips_yob)
eststo eq5: quietly reg graddeg    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=23 & yob >= 1983, robust cluster(fips_yob)
eststo eq6: quietly reg occscore    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=28 & yob >= 1983, robust cluster(fips_yob)
eststo eq7: quietly reg unemp    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=28 & yob >= 1983, robust cluster(fips_yob)
eststo eq8: quietly reg foodstmp    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=28 & yob >= 1983, robust cluster(fips_yob)
eststo eq9: quietly reg uhrswork    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=28 & yob >= 1983, robust cluster(fips_yob)
eststo eq10: quietly reg ever_married    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=28 & yob >= 1983, robust cluster(fips_yob)
eststo eq11: quietly reg own_home    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=28 & yob >= 1983, robust cluster(fips_yob)
eststo eq12: quietly reg teenage_mother    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if male==0&age<=30 & yob >= 1983, robust cluster(fips_yob)
eststo eq13: quietly reg institutionalized  $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=18&age<=24&(male==1) & yob >= 1983, robust cluster(fips_yob)
eststo eq14: quietly reg college_enroll  $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=19&age<=24 & yob >= 1983, robust cluster(fips_yob)
eststo eq15: quietly reg ftwork_enroll    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=19&age<=24 & yob >= 1983, robust cluster(fips_yob)
eststo eq16: quietly reg math_level    $covars0_math_readcomp i.fips_resid division_birth#yob [pw=perwt] if age>=28 & yob >= 1983, robust cluster(fips_yob)
esttab using "results/allvars_stateadj_parentcol_census_mathcomp",  csv cells(b(star fmt(3))  se(par fmt(3))) replace
}